package org.inspursc.s0517.health.evaluation.dao;

import org.inspursc.s0517.health.evaluation.entity.InsAnRadio;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * institution dao
 */
public interface InsAnRadioDao extends JpaRepository<InsAnRadio, Integer> {
    /**
     *
     */
    List<InsAnRadio> findAllBySurveyIdAndOrganizationId(Integer suId, Integer organizationId);

    List<InsAnRadio> findAllByAssessmentResultId(Integer suAnswerId);

    /**
     * 关联删除问卷调查详情
     * @param assessmentResultId
     * @return
     */
    @Modifying
    @Query(value = "DELETE FROM t_institution_record WHERE assessment_result_id = :assessmentResultId")
    Integer deleteByAssessmentResultId(@Param("assessmentResultId") Integer assessmentResultId);
}
